import Vuex from 'vuex'
// import menu from '../util/menu'

const state = {
  sendSmsDisabled: false,
  msg: {
    show: false,
    type: 'info',
    width: '220px',
    content: 'message',
    duration: 3000,
    placement: 'top'
  },
  menuList: [],
  menuType: '',
  // 贝塔币列表是否要刷新
  moneyUserListNeedFresh: false,
  // 首页广告列表是否要刷新
  indexAdListNeedFresh: false,
  // 通用广告列表是否要刷新
  gaoListNeedFresh: false,
  // 迷你组合广告列表是否要刷新
  miniAdListNeedFresh: false,
  // 迷你组合banner列表是否要刷新
  miniBannerListNeedFresh: false,
  // 配置活动首页是否刷新
  acListNeedFresh: false,
  // 收费组合列表是否刷新
  ptListNeedFresh: false,
  // 港股组合列表是否刷新
  hkListNeedFresh: false,
  // 是否隐藏分页标签
  isHidePages: false,
  // 热门组合是否要刷新
  hotPortfolioListNeedFresh: false,
  // 全部组合是否要刷新
  portfolioListNeedFresh: false,
  // 普通活动列表是否需要刷新
  acCustomListNeedFresh: false,
  miniPrizeListNeedFresh: false,
  miniCodeListNeedFresh: false,
  customMsgListNeedFresh: false,
  customFakeListNeedFresh: false,
  activityStoreId: null,
  activityStoreName: '',
  prizeStoreId: null,
  prizeStoreName: '',
  // 国信开户活动列表是否刷新
  guoxinListNeedFresh: false,
  // 国信开户活动邀请列表是否刷新
  guoxinInviteListNeedFresh: false,
  // 华林开户活动列表是否刷新
  hualinListNeedFresh: false,
  // 华林开户活动邀请列表是否刷新
  hualinInviteListNeedFresh: false,
  // 投票列表是否刷新
  votesTopListNeedFresh: false,
  // 充流量是否刷新
  dataflowListNeedFresh: false,
  // 存股宝列表是否刷新
  CGBListNeedFresh: false,
  // 推广员列表是否刷新
  promoterListNeedFresh: false,
  // 推广员审核列表是否刷新
  promoterAuditListNeedFresh: false,
  // 推广员发奖规则列表是否刷新
  promoterRuleListNeedFresh: false,
  // 邀请好友列表是否刷新
  inviteListFresh: false,
  // 投研大咖说相关列表是否需要刷新
  castTalkNeedFresh: false,
  // 专家库列表是否需要刷新
  expertNeedFresh: false,
  // 港股入金审核列表是否需要刷新
  voucherAuditNeedFresh: false,
  announcementListNeedFresh: false,
  // 投顾组合类型
  payType: 1,
  // 智能助手问答库是否刷新
  AIQuestionListNeedFresh: false,
  openAd: {
    securityCode: '',
    location: ''
  },
  // 收费课程是否需要刷新
  classesListNeedFresh: false,
  buyerList: []
}

const mutations = {
  SEND_SMS_DISABLED(state, bool) {
    state.sendSmsDisabled = bool
  },
  SET_ALERT_MSG(
    state,
    {
      type = 'info',
      dismissable = false,
      width = '220px',
      content,
      duration = 3000,
      placement = 'top'
    }
  ) {
    state.msg = {
      show: true,
      dismissable: dismissable,
      type: type,
      duration: duration,
      width: width,
      placement: placement,
      content: content || '未知错误信息'
    }
  },
  SET_MENU_LIST(state, list) {
    state.menuList = list
  },
  SET_MENU_TYPE(state, type) {
    state.menuType = type
  },
  UPDATE_ACTIVITY_FRESH(state, bool) {
    state.acListNeedFresh = !!bool
  },
  UPDATE_CUSTOM_FRESH(state, bool) {
    state.acCustomListNeedFresh = !!bool
  },
  UPDATE_GUOXIN_FRESH(state, bool) {
    state.guoxinListNeedFresh = !!bool
  },
  UPDATE_GUOXIN_INVITE_FRESH(state, bool) {
    state.guoxinInviteListNeedFresh = !!bool
  },
  UPDATE_HUALIN_FRESH(state, bool) {
    state.hualinListNeedFresh = !!bool
  },
  UPDATE_HUALIN_INVITE_FRESH(state, bool) {
    state.hualinInviteListNeedFresh = !!bool
  },
  UPDATE_VOTES_TOPLIST_FRESH(state, bool) {
    state.votesTopListNeedFresh = !!bool
  },
  UPDATE_PRIZE_FRESH(state, bool) {
    state.miniPrizeListNeedFresh = !!bool
  },
  IMPORT_CODE_FRESH(state, bool) {
    state.miniCodeListNeedFresh = !!bool
  },
  UPDATE_MSG_FRESH(state, bool) {
    state.customMsgListNeedFresh = !!bool
  },
  UPDATE_FAKE_FRESH(state, bool) {
    state.customFakeListNeedFresh = !!bool
  },
  SET_ACTIVITY_ID(state, params) {
    state.activityStoreId = +params.activityId
    state.activityStoreName = params.activityName
  },
  SET_PRIZE_ID(state, params) {
    state.prizeStoreId = +params.prizeId
    state.prizeStoreName = params.prizeName
  },
  PT_FRESH(state, bool) {
    state.ptListNeedFresh = !!bool
  },
  HK_FRESH(state, bool) {
    state.hkListNeedFresh = !!bool
  },
  UPDATE_MONEY_FRESH(state, bool) {
    state.moneyUserListNeedFresh = !!bool
  },
  INDEX_AD_LIST_NEED_FRESH(state, bool) {
    state.indexAdListNeedFresh = !!bool
  },
  GAO_LIST_NEED_FRESH(state, bool) {
    state.gaoListNeedFresh = !!bool
  },
  MINI_AD_LIST_NEED_FRESH(state, bool) {
    state.miniAdListNeedFresh = !!bool
  },
  MINI_BANNER_LIST_NEED_FRESH(state, bool) {
    state.miniBannerListNeedFresh = !!bool
  },
  HOT_PORTFOLIO_LIST_NEED_FRESH(state, bool) {
    state.hotPortfolioListNeedFresh = !!bool
  },
  PORTFOLIO_LIST_NEED_FRESH(state, bool) {
    state.portfolioListNeedFresh = !!bool
  },
  DATAFLOW_NEED_FRESH(state, bool) {
    state.dataflowListNeedFresh = !!bool
  },
  CGB_LIST_NEED_FRESH(state, bool) {
    state.CGBListNeedFresh = !!bool
  },
  PROMOTER_LIST_NEED_FRESH(state, bool) {
    state.promoterListNeedFresh = !!bool
  },
  PROMOTER_AUDIT_LIST_NEED_FRESH(state, bool) {
    state.promoterAuditListNeedFresh = !!bool
  },
  PROMOTER_RULE_LIST_NEED_FRESH(state, bool) {
    state.promoterRuleListNeedFresh = !!bool
  },
  INVITE_LIST_FRESH(state, bool) {
    state.inviteListFresh = !!bool
  },
  INVEST_LECTURE_LIST_FRESH(state, bool) {
    state.inviteListFresh = !!bool
  },
  SET_PAY_TYPE(state, payType) {
    state.payType = payType
  },
  AI_QUESTION_NEED_FRESH(state, bool) {
    state.AIQuestionListNeedFresh = !!bool
  },
  UPDATE_OPEN_NAME(state, params) {
    state.openAd.securityCode = params.securityCode
    state.openAd.location = params.location
  },
  CAST_TALK_NEED_FRESH(state, bool) {
    state.castTalkNeedFresh = !!bool
  },
  EXPERT_NEED_FRESH(state, bool) {
    state.expertNeedFresh = !!bool
  },
  VOUCHER_AUDIT_NEED_FRESH(state, bool) {
    state.voucherAuditNeedFresh = !!bool
  },
  ANNOUNCEMENT_LIST_NEED_FRESH(state, bool) {
    state.announcementListNeedFresh = !!bool
  },
  CLASSES_LIST_NEED_FRESH(state, bool) {
    state.classesListNeedFresh = !!bool
  },
  SET_BUYER_LIST(state, list) {
    state.buyerList = list.data.list
  }
}

export default new Vuex.Store({
  state,
  mutations
})
